﻿using ViazyNetCore.Permission.Descriptor;
using ViazyNetCore.Permission.Modules;

namespace ViazyNetCore.Permission
{
    public class PrimssionKeyDataSeed : IPrimssionKeyDataSeed
    {
        private readonly IApiManager _apiManager;
        private readonly PermissionService _permissionService;

        public PrimssionKeyDataSeed(IApiManager apiManager, PermissionService permissionService)
        {
            this._apiManager = apiManager;
            this._permissionService = permissionService;
        }

        public async Task CreatePrimissionKeyAsync()
        {
            foreach (var primssion in this._apiManager.GetPermissionKeys())
            {
                await _permissionService.AddPermission(primssion, primssion, true);
            }
        }
    }
}
